package hmvc4gwt.client.component;

import java.util.List;

import hmvc4gwt.client.controller.IController;
import hmvc4gwt.client.event.IHmvcEvent;
import hmvc4gwt.client.event.IHmvcEventListener;
import hmvc4gwt.client.model.IModel;
import hmvc4gwt.client.view.IView;


/**
 * The Implementation iss an Component
 * 
 * @author jens.meiss
 *
 */

public interface IComponent extends ITerminateAble {
	/**
	 * adds an Controller-Only-Child-Component
	 */
	public IComponent addChildComponent(IController controller);
	
	/**
	 * adds an Controller-Model-Child-Component
	 * @param controller
	 * @param model
	 */
	public IComponent addChildComponent(IController controller, IModel model);
	
	/**
	 * adds an Model-View-Control-Child-Component
	 */
	public IComponent addChildComponent(IController controller, IModel model, IView view);
	
	/**
	 * adds an View-Controller-Child-Component
	 * @param controller
	 * @param view
	 * @return
	 */
	public IComponent addChildComponent(IController controller, IView view);
	
	/**
	 * for testing only
	 */
	public boolean containsChildComponent(IComponent component);
	
	/**
	 * fires an Event to the Component
	 */
	public void fireEvent(IHmvcEvent event, boolean up, boolean local, boolean down);
	
	/**
	 * getter for the Controller of the Component
	 */
	public IController getController();
	
	/**
	 * getter for the Model of the Component
	 */
	public IModel getModel();

	/**
	 * getter of the parent-Component
	 */
	public IComponent getParentComponent();
	
	/**
	 * getter for the View of the Component
	 */
	public IView getView();
	
	/**
	 * registers an local-Listeners
	 * @param the Class of the Event to Listen to
	 * @param the Listener for the Event
	 */
	public void register(Class classOfEvent, IHmvcEventListener listener);
	
	/**
	 * removes an Listener for an Event
	 */
	public void removeListener(Class classOfEvent, IHmvcEventListener listener);
	
	/**
	 * setter for the Controller of the Component
	 */
	public void setController(IController controller);
	
	/**
	 * setter for the Model of the Component
	 */
	public void setModel(IModel model);
	
	/**
	 * setter of the parent-Component
	 * @param controller
	 */
	public void setParentComponent(IComponent parentComponent);
	
	/**
	 * setter for the View of the Component
	 */
	public void setView(IView view);
	
	/**
	 * delegate to listTerminatedChilds.add()
	 */
	public void addTerminatedChildComponent(IComponent component);
	
	/**
	 * returns a List of all Terminated Child-Components
	 */
	public List getListTerminatedChildComponents();
	
	/**
	 * removes all Terminated Child-Components
	 */
	public void removeTerminatedChildComponents();
}
